package client;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;

public class Screen_SendBtc extends JPanel {
	private JLabel lblsendBtcMenu;
	private JLabel lblsendAmountBtc;
	private JLabel lblcbsmailReceive;
	private JTextField tfamountBtc;
	private JTextField tfcbsmailReceive;
	private JButton btnSendBtc;
	private JButton btnReturn;

	/**
	 * Create the panel.
	 */

	public Screen_SendBtc() {
		setBackground(UIManager.getColor("Label.background"));
		setLayout(null);
		setSize(320, 480);

		lblsendBtcMenu = new JLabel("Send Bitcoins");
		lblsendBtcMenu.setOpaque(true);
		lblsendBtcMenu.setBackground(UIManager.getColor("Label.background"));
		lblsendBtcMenu.setHorizontalAlignment(SwingConstants.CENTER);
		lblsendBtcMenu.setForeground(Color.BLACK);
		lblsendBtcMenu.setFont(new Font("Eurostile", Font.BOLD, 16));
		lblsendBtcMenu.setBounds(0, 35, 320, 50);
		add(lblsendBtcMenu);

		lblsendAmountBtc = new JLabel("Enter BTC amount to send");
		lblsendAmountBtc.setOpaque(true);
		lblsendAmountBtc.setBackground(UIManager.getColor("Label.background"));
		lblsendAmountBtc.setHorizontalAlignment(SwingConstants.LEFT);
		lblsendAmountBtc.setForeground(Color.BLACK);
		lblsendAmountBtc.setFont(new Font("Eurostile", Font.PLAIN, 13));
		lblsendAmountBtc.setBounds(64, 110, 320, 16);
		add(lblsendAmountBtc);

		tfamountBtc = new JTextField();
		tfamountBtc.setHorizontalAlignment(SwingConstants.LEFT);
		tfamountBtc.setBounds(60, 130, 200, 35);
		tfamountBtc.setColumns(10);
		tfamountBtc.setFont(new Font("Eurostile", Font.PLAIN, 12));
		add(tfamountBtc);
		tfamountBtc.setColumns(10);

		lblcbsmailReceive = new JLabel("Enter receivers CBS-mail");
		lblcbsmailReceive.setOpaque(true);
		lblcbsmailReceive.setBackground(UIManager.getColor("Label.background"));
		lblcbsmailReceive.setHorizontalAlignment(SwingConstants.LEFT);
		lblcbsmailReceive.setForeground(Color.BLACK);
		lblcbsmailReceive.setFont(new Font("Eurostile", Font.PLAIN, 13));
		lblcbsmailReceive.setBounds(64, 170, 320, 16);
		add(lblcbsmailReceive);

		tfcbsmailReceive = new JTextField();
		tfcbsmailReceive.setHorizontalAlignment(SwingConstants.LEFT);
		tfcbsmailReceive.setBounds(60, 190, 200, 35);
		tfcbsmailReceive.setColumns(10);
		tfcbsmailReceive.setFont(new Font("Eurostile", Font.PLAIN, 12));
		add(tfcbsmailReceive);
		tfcbsmailReceive.setColumns(10);

		btnSendBtc = new JButton("Send Bitcoins");
		btnSendBtc.setHorizontalAlignment(SwingConstants.CENTER);
		btnSendBtc.setFont(new Font("Eurostile", Font.PLAIN, 13));
		btnSendBtc.setBounds(60, 230, 200, 35);
		add(btnSendBtc);

		btnReturn = new JButton("Return to main menu");
		btnReturn.setFont(new Font("Eurostile", Font.BOLD, 14));
		btnReturn.setHorizontalAlignment(SwingConstants.CENTER);
		btnReturn.setBounds(60, 300, 200, 45);
		add(btnReturn);

	}

	/**
	 * Returns JButton
	 * 
	 * @return btnDeposit
	 */
	public JButton getBtnSendBtc() {
		return btnSendBtc;
	}

	public JButton getBtnReturn() {
		return btnReturn;
	}

	public double getAmountBtc() {
		try {
			return Double.parseDouble(tfamountBtc.getText().trim());
		} catch (NumberFormatException e) {
			return -1;
		}

	}

	public String getCbsmailReceive() {

		return tfcbsmailReceive.getText();

	}

	/**
	 * Clear the fields
	 */
	public void clearFields() {
		tfcbsmailReceive.setText("");
		tfamountBtc.setText("");
	}

	/**
	 * Add ActionListener to JButtons and JTextField
	 * 
	 * @param ActionListener
	 *            l
	 */
	public void addActionListener(ActionListener l) {
		btnSendBtc.addActionListener(l);
		btnReturn.addActionListener(l);
		tfamountBtc.addActionListener(l);
		tfcbsmailReceive.addActionListener(l);
	}
}
